function plotline(IN,w,XLABEL)    
% plot the weight figure for empirical exercises

    IN = [1e10 IN -1e10];
    N = length(IN);
    TAR = [];
    for i = 1:N-1
        int = w<IN(i)&w>IN(i+1);
        wt = w(int);
        TAR = [TAR;wt];
        SAVE(i,:) = [mean(wt) length(wt)];
    end
    plot(TAR,'o')
    if nargin == 2
        XLABEL = 'Forecaster';
    end
    xlabel(XLABEL);
    ylabel('Weight')
    xlim([0 length(w)+1])
    IN2 = [0; cumsum(SAVE(:,2))];
    hold on
    for i = 1:length(IN2)-1
        xi = [IN2(i)+0.5 IN2(i+1)+0.5];
        yi = ones(length(xi),1)*SAVE(i,1);
        plot(xi,yi,'r')
    end
    hold off    
    legend('Weight','Group Mean')
end



